package cn.tedu.online.day01;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class StudentTest {
    public static void main(String[] args) {
        List<Student> list = new ArrayList<>();
        Student student  = new Student(1,"tom",20);
        Student student1  = new Student(6,"jack",22);
        Student student2  = new Student(4,"rose",26);
        Student student3  = new Student(2,"jerry",29);
        Student student4  = new Student(0,"nike",25);
        Student student5  = new Student(9,"tony",24);

        list.add(student);
        list.add(student1);
        list.add(student2);
        list.add(student3);
        list.add(student4);
        list.add(student5);

        //Collections.sort(list);

        Collections.sort(list, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.getAge().compareTo(o2.getAge());
            }
        });

        for (Student s: list){
            System.out.println(s);
        }
    }
}
